/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package qltieuhoc;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JInternalFrame;

/**
 *
 * @author Le Thai
 */
public class MainForm extends javax.swing.JFrame {

    /**
     * Creates new form MainForm
     */
    public MainForm() {
        initComponents();
        moveCenter();
        
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        jToolBar1 = new javax.swing.JToolBar();
        btnQuanLyHocSinh = new javax.swing.JButton();
        btnQuanLyNhanVien = new javax.swing.JButton();
        btnQuanLyDiemSo = new javax.swing.JButton();
        btnXepLop = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        loginMenuItem = new javax.swing.JMenuItem();
        LogoutMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        toolsMenu = new javax.swing.JMenu();
        adminMenuItem = new javax.swing.JMenu();
        bdSettingMenuItem = new javax.swing.JMenuItem();
        dbBackupMenuItem = new javax.swing.JMenuItem();
        optionsMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        desktopPane.setBackground(new java.awt.Color(153, 153, 153));

        jToolBar1.setFloatable(false);
        jToolBar1.setToolTipText("");

        btnQuanLyHocSinh.setText("Học Sinh");
        btnQuanLyHocSinh.setActionCommand("");
        btnQuanLyHocSinh.setContentAreaFilled(false);
        btnQuanLyHocSinh.setFocusCycleRoot(true);
        btnQuanLyHocSinh.setFocusPainted(false);
        btnQuanLyHocSinh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnQuanLyHocSinh.setOpaque(true);
        btnQuanLyHocSinh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnQuanLyHocSinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuanLyHocSinhActionPerformed(evt);
            }
        });
        jToolBar1.add(btnQuanLyHocSinh);

        btnQuanLyNhanVien.setText("Nhân Viên");
        btnQuanLyNhanVien.setActionCommand("");
        btnQuanLyNhanVien.setContentAreaFilled(false);
        btnQuanLyNhanVien.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        btnQuanLyNhanVien.setFocusCycleRoot(true);
        btnQuanLyNhanVien.setFocusPainted(false);
        btnQuanLyNhanVien.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnQuanLyNhanVien.setOpaque(true);
        btnQuanLyNhanVien.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnQuanLyNhanVien);

        btnQuanLyDiemSo.setText("Điểm Số");
        btnQuanLyDiemSo.setToolTipText("");
        btnQuanLyDiemSo.setActionCommand("");
        btnQuanLyDiemSo.setContentAreaFilled(false);
        btnQuanLyDiemSo.setFocusCycleRoot(true);
        btnQuanLyDiemSo.setFocusPainted(false);
        btnQuanLyDiemSo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnQuanLyDiemSo.setOpaque(true);
        btnQuanLyDiemSo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnQuanLyDiemSo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuanLyDiemSoActionPerformed(evt);
            }
        });
        jToolBar1.add(btnQuanLyDiemSo);

        btnXepLop.setText("Xếp Lớp");
        btnXepLop.setContentAreaFilled(false);
        btnXepLop.setFocusCycleRoot(true);
        btnXepLop.setFocusPainted(false);
        btnXepLop.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnXepLop.setOpaque(true);
        btnXepLop.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnXepLop);

        menuBar.setPreferredSize(new java.awt.Dimension(97, 25));

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        loginMenuItem.setText("Login");
        loginMenuItem.setName(""); // NOI18N
        fileMenu.add(loginMenuItem);

        LogoutMenuItem.setLabel("Logout");
        fileMenu.add(LogoutMenuItem);

        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        toolsMenu.setText("Tools");

        adminMenuItem.setText("Admin");

        bdSettingMenuItem.setText("Database Settings");
        adminMenuItem.add(bdSettingMenuItem);

        dbBackupMenuItem.setText("Backup Data");
        adminMenuItem.add(dbBackupMenuItem);

        toolsMenu.add(adminMenuItem);

        optionsMenuItem.setText("Options");
        toolsMenu.add(optionsMenuItem);

        menuBar.add(toolsMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        contentMenuItem.setMnemonic('c');
        contentMenuItem.setText("Contents");
        helpMenu.add(contentMenuItem);

        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(desktopPane)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE))
                .addGap(0, 0, 0))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 551, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }
    
    
    //set form at center screen
    private void moveCenter(){
        Dimension dim= Toolkit.getDefaultToolkit().getScreenSize();
        int x=(dim.width-this.getWidth())/2;
        int y=(dim.height-this.getHeight())/2;
        this.setLocation(x,y);
    }
    
    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void btnQuanLyHocSinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuanLyHocSinhActionPerformed

        // TODO add your handling code here:
        boolean isOpen=false;
        JInternalFrame [] frames=desktopPane.getAllFrames();
        for(JInternalFrame frame:frames){
            if(frame.getTitle().equals("Quản Lý Học Sinh")){
               isOpen=true;
               break;
            }
        }
        if(!isOpen){
            FormQLHocSinh studenForm=new FormQLHocSinh();
            desktopPane.add(studenForm);
            
            studenForm.setVisible(true);
        }
        
        
        
    }//GEN-LAST:event_btnQuanLyHocSinhActionPerformed

    private void btnQuanLyDiemSoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuanLyDiemSoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnQuanLyDiemSoActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem LogoutMenuItem;
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenu adminMenuItem;
    private javax.swing.JMenuItem bdSettingMenuItem;
    private javax.swing.JButton btnQuanLyDiemSo;
    private javax.swing.JButton btnQuanLyHocSinh;
    private javax.swing.JButton btnQuanLyNhanVien;
    private javax.swing.JButton btnXepLop;
    private javax.swing.JMenuItem contentMenuItem;
    private javax.swing.JMenuItem dbBackupMenuItem;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JMenuItem loginMenuItem;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem optionsMenuItem;
    private javax.swing.JMenu toolsMenu;
    // End of variables declaration//GEN-END:variables
}